package vip.liux.contracts.shared.value;


import jakarta.validation.constraints.NotBlank;

import java.io.Serializable;
import java.util.List;
import java.util.function.Function;

public record Select(@NotBlank String label, @NotBlank String value) implements Serializable {
    public static <T> List<Select> fromList(List<T> items, Function<T, String> labelFunction, Function<T, String> valueFunction) {
        return items.stream()
                .map(item -> new Select(labelFunction.apply(item), valueFunction.apply(item)))
                .toList();
    }
}